#!/usr/bin/env python
# encoding: utf-8

import os
import string
import os.path
import sys

top = "."
out = "waf-build"

def options(ctx):
    ctx.load("gcc")

def configure(ctx):
    ctx.load("gcc")


def build(ctx):
    cwd = ctx.path.abspath()
    src_files = """
        music.c
        mixer.c
        load_voc.c
        load_aiff.c
        fluidsynth.c
        dynamic_fluidsynth.c
        effects_internal.c
        effect_stereoreverse.c
        effect_position.c
    """
    include_paths = [
            ctx.env.SDL_INCLUDE_PATH,
            cwd + "/libfluidsynth/include",
    ]
    library_paths = [
            #cwd + "/../../sdk/SDL2/lib",
            ctx.env.SDL_LIB_PATH
    ]
    defines = [
            "USE_FLUIDSYNTH_MIDI",
            "MID_MUSIC",
            "HAVE_STRDUP",
    ]
    cwd = ctx.path.abspath()
    ctx.recurse(["libfluidsynth"])
    ctx.stlib(
            source = src_files, 
            target = "zaudio", 
            cflags = "-O2",
            defines = defines,
            includes = include_paths,
            libpath = library_paths,
            name = "zaudio",
            use = "fluidsynth"
            )

